<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>订单支付</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
    <script src="js/bootstrap.min.js"></script>
    <script src="js/vendor/jquery-1.12.4.min.js"></script>
    <script src="js/vendor/jquery-1.12.4.min.js"></script>

    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul, ol {
            list-style: none;
        }

        body {
            font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande",
            sans-serif;
        }

        .tab-head {
            margin-left: 120px;
            margin-bottom: 10px;
        }

        .tab-content {
            clear: left;
            display: none;
        }

        h2 {
            border-bottom: solid #02aaf1 2px;
            width: 200px;
            height: 25px;
            margin: 0;
            float: left;
            text-align: center;
            font-size: 16px;
        }

        .selected {
            color: #FFFFFF;
            background-color: #02aaf1;
        }

        .show {
            clear: left;
            display: block;
        }

        .hidden {
            display: none;
        }

        .new-btn-login-sp {
            padding: 1px;
            display: inline-block;
            width: 75%;
        }

        .new-btn-login {
            background-color: #02aaf1;
            color: #FFFFFF;
            font-weight: bold;
            border: none;
            width: 100%;
            height: 30px;
            border-radius: 5px;
            font-size: 16px;
        }

        #main {
            width: 100%;
            margin: 0 auto;
            font-size: 14px;
        }

        .red-star {
            color: #f00;
            width: 10px;
            display: inline-block;
        }

        .null-star {
            color: #fff;
        }

        .content {
            margin-top: 5px;
        }

        .content dt {
            width: 100px;
            display: inline-block;
            float: left;
            margin-left: 20px;
            color: #666;
            font-size: 13px;
            margin-top: 8px;
        }

        .content dd {
            margin-left: 120px;
            margin-bottom: 5px;
        }

        .content dd input {
            width: 85%;
            height: 28px;
            border: 0;
            -webkit-border-radius: 0;
            -webkit-appearance: none;
        }

        #foot {
            margin-top: 10px;
            position: absolute;
            bottom: 15px;
            width: 100%;
        }

        .foot-ul {
            width: 100%;
        }

        .foot-ul li {
            width: 100%;
            text-align: center;
            color: #666;
        }

        .note-help {
            color: #999999;
            font-size: 12px;
            line-height: 130%;
            margin-top: 5px;
            width: 100%;
            display: block;
        }

        #btn-dd {
            margin: 20px;
            text-align: center;
        }

        .foot-ul {
            width: 100%;
        }

        .one_line {
            display: block;
            height: 1px;
            border: 0;
            border-top: 1px solid #eeeeee;
            width: 100%;
            margin-left: 20px;
        }

        .am-header {
            display: -webkit-box;
            display: -ms-flexbox;
            display: box;
            width: 100%;
            position: relative;
            padding: 7px 0;
            -webkit-box-sizing: border-box;
            -ms-box-sizing: border-box;
            box-sizing: border-box;
            background: #1D222D;
            height: 50px;
            text-align: center;
            -webkit-box-pack: center;
            -ms-flex-pack: center;
            box-pack: center;
            -webkit-box-align: center;
            -ms-flex-align: center;
            box-align: center;
        }

        .am-header h1 {
            -webkit-box-flex: 1;
            -ms-flex: 1;
            box-flex: 1;
            line-height: 18px;
            text-align: center;
            font-size: 18px;
            font-weight: 300;
            color: #fff;
        }
    </style>
</head>
<body text=#000000 bgColor="#ffffff" leftMargin=0 topMargin=4>
<header class="am-header">
    <h1>易购商城-订单支付</h1>
</header>
<div id="main" class="container-fluid">
    <div class="row col-xs-6 col-xs-offset-3">
        <form name=alipayment action=alipay.trade.page.pay.jsp method=post
              target="_blank">
            <div id="body1" class="show" name="divcontent">
                <dl class="content">
                    <dt>商户订单号 ：</dt>
                    <dd>
                        <input id="WIDout_trade_no" name="WIDout_trade_no" readonly/>
                    </dd>
                    <hr class="one_line">
                    <dt>订单创建时间 ：</dt>
                    <dd>
                        <input id="WIDsubject" name="WIDsubject" readonly/>
                    </dd>
                    <hr class="one_line">
                    <dt>付款金额 ：</dt>
                    <dd>
                        <input id="WIDtotal_amount" name="WIDtotal_amount" readonly/>
                    </dd>
                    <hr class="one_line">
                    <dt>商品描述：</dt>
                    <dd>
                        <textarea id="WIDbody" name="WIDbody" readonly style="width: 800px;height:auto;resize:none;border: 0"></textarea>
<!--                         <input id="WIDbody" name="WIDbody" readonly/>-->
                    </dd>
                    <hr class="one_line">
                    <dt></dt>
                    <dd id="btn-dd">
						<span class="new-btn-login-sp">
							<button class="new-btn-login" type="submit"
                                    style="text-align: center;" onclick="window.close();">付 款</button>
						</span> <span class="note-help">如果您点击“付款”按钮，即表示您同意该次的执行操作。</span>
                    </dd>
                </dl>
            </div>
        </form>
    </div>


    <div id="foot">
        <ul class="foot-ul">
            <li>支付宝版权所有 2015-2018 ALIPAY.COM</li>
        </ul>
    </div>
</div>
</body>
<script language="javascript">
    function initData() {
        //通过localStorage获取订单编号
        let orderNo = localStorage.getItem('local_shopping_orderNo');
        //发起ajax请求获取数据
        $.ajax({
            url: '${pageContext.servletContext.contextPath}/order',
            type: 'post',
            dataType: 'json',
            data: {method: 'getOrderInfo',orderNo:orderNo},
            success: function(_data) {
                let price = 0;
                let goodTitle = '';
                let oNum = 0;
                let orderTime = _data[0].createTime;

                for (let i = 0; i < _data.length; i++) {
                    price += _data[i].goodPrice;
                    goodTitle += _data[i].goodsTitle
                    if (i < _data.length - 1) {
                        goodTitle += '、';
                    }
                    oNum += _data[i].goodNum;
                }
                goodTitle += '等 '+oNum+" 件商品";
                $("#WIDout_trade_no").val(orderNo);//订单号
                $("#WIDsubject").val(getDateTime(orderTime));//订单创建时间
                $("#WIDtotal_amount").val(price);//付款金额
                $("#WIDbody").attr('rows', oNum);
                $("#WIDbody").val(goodTitle);//商品描述
                localStorage.removeItem('local_shopping_orderNo');
            }
        })
    }

    initData();

    //时间戳转日期
    function getDateTime(time) {
        return new Date(time).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
    }
</script>
</html>